package arithmetic;

import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Hashtable;

public class Test3 {
    @Test
    void run() {
        int re = fun(10);
        System.out.println(re);
    }

    private static int fun(int i) {
        if (i == 1) {
            return 1;
        }
        return i * fun(i - 1);
    }

    /**
     * 冒泡算法
     */
    @Test
    public void dg() {
        int[] arr = {25, 12, 54, 62, 87, 56};
        for (int i = arr.length - 1; i >= 0; i--) {
            for (int j = i - 1; j >= 0; j--) {
                if (bj(arr[i], arr[j])) {
                    th(arr, i, j);
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }

    /**
     * 选择排序
     */
    @Test
    public void xz() {
        int[] arr = {25, 12, 54, 62, 87, 56};
        for (int i = 0; i < arr.length; i++) {
            int minIndex = i;
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[minIndex] > arr[j]) {
                    minIndex = j;
                }
            }
            th(arr, i, minIndex);
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
    public void cr(){
        int[] arr = {25, 12, 54, 62, 87, 56};
        for (int i = 1; i < arr.length; i++) {
            for (int j = i; j >= 0; j--) {
                    if (arr[j-1]> arr[j]){

                    }else {

                    }
            }
        }
    }
    /**
     * 比较大小
     *
     * @param a
     * @param b
     * @return
     */
    public static boolean bj(int a, int b) {
        return a < b;
    }

    /**
     * 元素替换
     *
     * @param arr
     * @param sourceIndx
     * @param replaceIndx
     */
    public void th(int[] arr, int sourceIndx, int replaceIndx) {
        int source = arr[sourceIndx];
        int replace = arr[replaceIndx];
        arr[sourceIndx] = replace;
        arr[replaceIndx] = source;

new HashMap<>();
new Hashtable<>();
    }
}
